//
//  YSPageStyle.m
//  YSPageViewExample_OC
//
//  Created by MOLBASE on 2017/12/5.
//  Copyright © 2017年 YangShen. All rights reserved.
//

#import "YSPageStyle.h"

@implementation YSPageStyle

- (instancetype)init {
    if (self = [super init]) {
        /// 初始化
        self.isScrollEnable = YES;
        
        self.titleBackgroundColor = [UIColor colorWithWhite:1 alpha:0.7];
        self.titleHeight = 44.0;
        self.isHaveTitleSeparator = YES;
        self.titleSeparatorColor = [UIColor lightGrayColor];
        
        self.titleMargin = 20.0;
        self.titleFont = [UIFont systemFontOfSize:15];
        self.titleNormalColor = [UIColor blackColor];
        self.titleSelectedColor = [UIColor orangeColor];
        
        self.titleColorGradientStyle = YSTitleColorGradientStyleRGB;
        
        self.titleTransformScale = 1.3;
        
        self.coverColor = [UIColor lightGrayColor];
        self.coverCornerRadius = 5.0;
        
        self.underLineHeight = 2.0;
        self.underLineColor = [UIColor redColor];
    }
    return self;
}

#pragma mark -
#pragma mark Setter
- (void)setIsShowTitleScale:(BOOL)isShowTitleScale {
    if (_isShowUnderLine && isShowTitleScale) {
        // 抛异常
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"字体放大效果和角标不能同时使用。" userInfo:nil];
        [excp raise];
    }
    
    if (_isShowTitleCover && isShowTitleScale) {
        // 抛异常
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"字体放大效果和遮罩不能同时使用。" userInfo:nil];
        [excp raise];
    }
    _isShowTitleScale = isShowTitleScale;
}

- (void)setIsShowUnderLine:(BOOL)isShowUnderLine {
    if (_isShowTitleScale && isShowUnderLine) {
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"字体放大效果和角标不能同时使用。" userInfo:nil];
        [excp raise];
    }
    _isShowUnderLine = isShowUnderLine;
}

- (void)setIsShowTitleCover:(BOOL)isShowTitleCover {
    if (!_isScrollEnable && isShowTitleCover) {
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"遮罩在不能滚动时无法使用。" userInfo:nil];
        [excp raise];
    }
    
    if (_isShowTitleScale && isShowTitleCover) {
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"字体放大效果和遮罩不能同时使用。" userInfo:nil];
        [excp raise];
    }
    _isShowTitleCover = isShowTitleCover;
}

- (void)setTitleWidth:(CGFloat)titleWidth {
    if (!_isScrollEnable && titleWidth > 0) {
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"标题宽度在不能滚动时无法使用。" userInfo:nil];
        [excp raise];
    }
    _titleWidth = titleWidth;
}

- (void)setIsScrollEnable:(BOOL)isScrollEnable {
    if (_isShowTitleCover && !isScrollEnable) {
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"遮罩在不能滚动时无法使用。" userInfo:nil];
        [excp raise];
    }
    
    if (_titleWidth > 0 && !isScrollEnable) {
        NSException *excp = [NSException exceptionWithName:@"YSPageViewException" reason:@"标题宽度在不能滚动时无法使用。" userInfo:nil];
        [excp raise];
    }
    
    _isScrollEnable = isScrollEnable;
}

@end
